//
//  BaseViewController.m
//  SportSocial
//
//  Created by yull on 14/11/19.
//  Copyright (c) 2014年 yull. All rights reserved.
//

#import "BaseViewController.h"
#import <MobClick.h>

@implementation BaseViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) {
        self.automaticallyAdjustsScrollViewInsets = NO;
        
        self.edgesForExtendedLayout = UIRectEdgeBottom;
    }
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.navigationController.navigationBar setBarTintColor:Navibar_Color];
    
    //测试代码
    self.view.backgroundColor = [UIColor whiteColor];
}

- (void)addCommonBackButton
{
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    leftButton.frame = CGRectMake(0, 0, 28, 26);
    [leftButton setImage:[UIImage imageNamed:@"title_iconback"] forState:UIControlStateNormal];
    [leftButton setImage:[UIImage imageNamed:@"title_iconback_selection"] forState:UIControlStateHighlighted];
    [leftButton addTarget:self.navigationController action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    spaceItem.width = -10;
    self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:spaceItem,leftItem, nil];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    }
    
    [MobClick beginLogPageView:NSStringFromClass(self.class)];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    [MobClick endLogPageView:NSStringFromClass(self.class)];
}
@end
